package org.dydl.dao.system.repository;

import java.util.List;

import org.dydl.model.system.MaterialsPurchaseDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;


@Repository
public interface IMaterialsPurchaseDetailRepository extends CrudRepository<MaterialsPurchaseDetail, Integer>,JpaSpecificationExecutor<MaterialsPurchaseDetail> {

	@Query(value = "SELECT * FROM materials_purchase_detail WHERE PURCHASE_SINGLE_NO = :purchaseSingleNo",nativeQuery = true)
	List<MaterialsPurchaseDetail> findDetailByPurchaseSingleNo(@Param("purchaseSingleNo")String purchaseSingleNo);
	
	@Modifying
//	@Transactional
	@Query(value = "DELETE FROM materials_purchase_detail WHERE PURCHASE_SINGLE_NO = :purchaseSingleNo",nativeQuery = true)
	void deleteDetail(@Param("purchaseSingleNo")String purchaseSingleNo);
}
